package com.qdlc.p2p.biz.processor.event;

import java.io.Serializable;

import com.qdlc.p2p.biz.processor.task.NoticeEmailTaskProcessor;
import com.qdlc.p2p.biz.processor.task.NoticeMessageTaskProcessor;
import com.qdlc.p2p.biz.processor.task.NoticeSmsTaskProcessor;
import com.qdlc.p2p.common.constant.NoticeTplNid;
import com.qdlc.p2p.common.core.queue.event.AbstractReplayValueEvent;
import com.qdlc.p2p.dal.dto.Notice;

/**
 * 定义短信、邮件队列事件
 * @author linya 2016-01-17
 */
public class NoticeValueEvent extends AbstractReplayValueEvent implements Serializable {
	
	Notice notice;
	
	protected void initTaskProcessorClass(Notice notice){
		if(notice == null){
			throw new IllegalArgumentException("the notice of NoticeEvent is null!");
		}
		byte noticeType = Byte.parseByte(notice.getType());
		switch (noticeType) {
        case NoticeTplNid.NOTICE_SMS:
            this.setTaskProcessorClass(NoticeSmsTaskProcessor.class);
            break;
        case NoticeTplNid.NOTICE_EMAIL:
            this.setTaskProcessorClass(NoticeEmailTaskProcessor.class);
            break;
        case NoticeTplNid.NOTICE_MESSAGE:
            this.setTaskProcessorClass(NoticeMessageTaskProcessor.class);
            break;
	    }		
	}

	public Notice getNotice() {
		return notice;
	}

	public void setNotice(Notice notice) {
		this.notice = notice;
		initTaskProcessorClass(notice);
	}
	
}
